package utils;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.io.PrintWriter;

import problem.Heuristic;
import problem.logic;
import env.City;
import env.Move;
import utils.AiSearch.AiNode;

public class AstarStrategy implements Strategy {
	
	private City goal;
	
	
	public AstarStrategy(City goal) {
		this.goal = goal;
//		PrintStream out;
//		try {
//			out = new PrintStream(new FileOutputStream("output.txt"));
//			System.setOut(out);
//		} catch (FileNotFoundException e) {
//			
//			e.printStackTrace();
//		}
		
	}

	@Override
	public void calcCost(AiNode n1, AiNode n2, Move move) {
		
		int heuristic = Heuristic.getHeuristic(n2.copiedWorld, n2.copiedWorld.getCityByName(goal.getName()));
		n2.cost = n2.agentScore + heuristic;
//		if (n1.c.getName().equals("3") && n2.c.getName().equals("4") && move.escort && move.chems && n1.agentScore==14){
//			System.out.print("stop");
//		}
		
		
		//		System.out.println("move: "+ move + " agent score: " + n2.agentScore +" heuristic:  "+ heuristic + " cost= " +n2.cost );
	}

}
